attach(fake.trypsin)
summary(fake.trypsin)

anova(lm(trypsin ~ grp))
anova(lm(trypsin ~ grpf))

model1 <- lm(trypsin ~ grp)  #linear model
model2 <- lm(trypsin ~ grpf) #one-way anova
anova(model1, model2)

anova(lm(trypsin ~ grp + grpf))

xbar_trypsin <- tapply(trypsin, grpf, mean)
stripchart(trypsin ~ grp, method = "jitter", jitter = 0.1, vertical = T, pch = 20, col = "blue")
lines(1:6, xbar_trypsin, type = "b", pch = 1, cex = 3, lty = 3, col = "red")

n <- c(32, 137, 38, 44, 16, 4)
tryp_mean <- c(128, 152, 194, 207, 215, 218)
tryp_sd <- c(50.9, 58.5, 49.3, 66.3, 60, 14)
gr <- 1:6
anova(lm(tryp_mean ~ gr + factor(gr), weights = n))
anova(lm(tryp_mean ~ gr, weights = n))

sum(tryp_sd^2 * (n - 1))
sum(n - 1)
sum(tryp_sd^2 * (n - 1)) / sum(n - 1)
